package cn.doctorpda.meeting.model;

import org.json.JSONObject;

import cn.doctorpda.meeting.config.AppConfig;
import cn.doctorpda.meeting.config.NetConfig;
import cn.doctorpda.meeting.okhttp.OkHttpUtils;
import cn.doctorpda.meeting.okhttp.callback.Callback;
import cn.doctorpda.meeting.utils.AESUtil;

/**
 * Created by huangjinlong on 2016/5/13.
 */
public class BaseModel implements IBaseModel{

    @Override
    public void postNetWorkStringData(String url, Callback callback, String... parameter){
        JSONObject object = new JSONObject();
        try {
            object.put("cityId", parameter[0]);
            object.put("page", parameter[1]);
        }catch (Exception e){
            e.printStackTrace();
        }
        String data = AESUtil.encrypt(object.toString(), AppConfig.AES_KEY);
        OkHttpUtils.post()
                .url(NetConfig.GET_HOME_INFO)
                .addParams("data", data)
                .addParams("source", "meeting")
                .build()
                .execute(callback);
    }

    @Override
    public void getNetWorkStringData(String url, Callback callback) {
        OkHttpUtils.get()
                .url(url)
                .build()
                .execute(callback);
    }
}
